package sg.edu.nus.iss.vmcs.store;

/*
 * Copyright 2003 ISS.
 * The contents contained in this document may not be reproduced in any
 * form or by any means, without the written permission of ISS, other
 * than for the purpose for which it has been supplied.
 *
 */

/**
 *The entity object stores the name of the name and price
 *
 * @version 3.0 5/07/2003
 * @author Olivo Miotto, Pang Ping Li
 */

public class DrinksBrand extends StoreObject{

	//Registry of Singleton Pattern
	private static final String DRINKS="drinks";
	private static java.util.Hashtable<String,DrinksBrand> objects;
	
	private int price;

	//Registry of Singleton Pattern
	private DrinksBrand() {
	}
	
	/**
	 * 
	 * @param name name for the drink brand
	 * @param price the price of drink brand in cents
	 */	
	//Registry of Singleton Pattern
//	public DrinksBrand(String name, int price) {
//		this.price = price;
//		this.name = name;
//	}
	
	//Registry of Singleton Pattern
	public static DrinksBrand getDrinksBrand(String name){
		DrinksBrand d;
		if(objects==null)
			objects=new java.util.Hashtable<String, DrinksBrand>();
		
		if(objects.containsKey(name)){
			d=objects.get(name);
		}else{
			d=new DrinksBrand();
			objects.put(name, d);
		}
		
		return d;
	}
	
	/**
	 * This method will set the price for the brand
	 * @param p price
	 */
	public void setPrice(int p) {
		price = p;	
		
		if(storeItem!=null)
			storeItem.notifyStoreContentChange();
	}
	
	/**
	 * This method will send the price of the requested drinks brand to the requester.
	 * @return price for the brand
	 */
	public int getPrice() {
		return (price);
	}

}
